<template>
	<div>
		<div class="content-card">
			<html-label title="基本信息">
				<el-button type="primary" @click="handleOperate"> 档案编辑 </el-button>
			</html-label>

			<DetailPage v-bind="detailConfig" :model="nowRowData"></DetailPage>
		</div>

		<el-drawer v-model="drawer" append-to-body title="档案编辑">
			<AplidForm v-bind="formConfig" v-if="drawer" v-model="formModel" @submit="onSubmit"></AplidForm>
		</el-drawer>
	</div>
</template>

<script setup lang="ts">
import apiMod from '@/apiMod/index'
import DetailPage from '@/views/aplid/DetailPage/index.vue'
import { ElMessage } from 'element-plus'
type Props = {
	api?: any
	paramsObj?: any
	nowRowData?: any
	detailConfig?: any
	formConfig?: any
}
const props = withDefaults(defineProps<Props>(), {
	nowRowData: {},
})
const emit = defineEmits(['refresh'])
const drawer = ref(false)
const formModel:any = ref({})
const handleOperate = () => {
	drawer.value = true
	formModel.value = {
		...props.nowRowData,
		password: '',
	}
}

const onSubmit = (form, done) => {
	apiMod[props.api.edit]({
		...form,
		...props.paramsObj,
	})
		.then((res) => {
			drawer.value = false
			ElMessage.success('操作成功!')
			done()
			emit('refresh')
		})
		.catch(() => {
			done()
		})
}
</script>

<style scoped>
.bottom {
	margin-top: 13px;
	line-height: 12px;
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.image {
	width: 100%;
	display: block;
}
</style>
